package com.brickworkers.codemaker.utils;

public class StringUtils {

	//把简单的表名转化为合理的类名
	//user_info ==> UserInfo
	//第一位小写变大写，如果存在斜杠，则需要把斜杠整形
	public static String getClassName(String tableName){
		String str = "";
		String[] strs = tableName.split("_");
		for (String string : strs) {
			str += string.substring(0, 1).toUpperCase() + string.substring(1);
		}
		return str;
	}
	
	
	//把列名转化为合理的列名
	//user_id ===>userId
	public static String getFormatRowName(String rowName){
		String str = "";
		String[] strs = rowName.split("_");
		str = strs[0];
		for (int i = 1; i < strs.length; i++) {
			str +=strs[i].substring(0, 1).toUpperCase() + strs[i].substring(1); 
		}
		return str;
	}
	
	public static void main(String[] args) {
		System.out.println(getFormatRowName("userinfo"));
		System.out.println(getFormatRowName("user_info"));
		System.out.println(getFormatRowName("user_info_message"));
	}
}
